var totop = document.getElementById("off");
var myTimer = -1;
totop.onclick = function () {
    var scrollTo = document.documentElement.scrollTop || document.body.scrollTop
    if (myTimer == -1) {
        myTimer = setInterval(() => {
            scrollTo -= 60
            if (scrollTo <= 0) {
                scrollTo = 0
                window.clearInterval(myTimer)
                myTimer = -1
            }

            window.scrollTo(0, scrollTo) //这是值  是指离开网页顶部的距离   
        }, 10);

    }
}
//滚动到一定高度会出现顶部通栏
onscroll = function () {
    var over = document.body.scrollTop;
    if (over > 600) {
        totop.style.display = "block";
    }
    if (over < 600) {
        totop.style.display = "none";
    }
}